package com.swlz.servlet;

import java.io.IOException;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.swlz.entity.MallProduct;
import com.swlz.entity.MallType;
import com.swlz.service.MallProductService;
import com.swlz.service.MallTypeService;
import com.swlz.service.impl.MallProductServiceImpl;
import com.swlz.service.impl.MallTypeServiceImpl;

@WebServlet("/mall-list.let")
public class MallProductListServlet extends HttpServlet{

	MallProductService mallProduct = new MallProductServiceImpl();
	MallTypeService mallType = new MallTypeServiceImpl();
	@Override
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		//获取参数
		Integer index = 0; 
		Integer len = 15;
		Integer index1 = 0;
		Integer len1 = 9;
		try {
			index = Integer.valueOf(request.getParameter("index"));
			index1 = Integer.valueOf(request.getParameter("index1"));
			len = Integer.valueOf(request.getParameter("len"));
			len1 = Integer.valueOf(request.getParameter("len1"));
		} catch (NumberFormatException e) {
			
		}
		//调用业务逻辑接口
		List<MallProduct> list = mallProduct.list(null, index, len);
		List<MallType> list1 = mallType.list(null, index1, len1);
		request.setAttribute("list", list);
		request.setAttribute("list1", list1);
		//跳转视图
		request.getRequestDispatcher("/index_jsp.jsp").forward(request, response);
	}
}
